import { HttpGet, HttpPost } from '@/api/index.js'

/**
 * 新增角色
 * @param role
 */
export const add = (role) => {
    return HttpPost('/admin/system/role/add', role)
}

/**
 * 删除角色
 * @param id
 */
export const deleteById = (id) => {
    return HttpPost('/admin/system/role/deleteById/' + id)
}

/**
 * 更新角色
 * @param role
 */
export const edit = (role) => {
    return HttpPost('/admin/system/role/update', role)
}

/**
 * 分页列表
 * @param search
 */
export const pageList = (search) => {
   return HttpGet('/admin/system/role/page', search)
}

/**
 * 列表
 * @param search
 */
export const list = (search) => {
    return HttpGet('/admin/system/role/list', search)
}

/**
 * 角色绑定用户
 * @param roleBindUsers
 */
export const bindUsers = (roleBindUsers) => {
    return HttpPost('/admin/system/role/bindUsers', bindUsers())
}

/**
 * 角色绑定的用户分页列表
 * @param search
 */
export const boundUserPageList = (search) => {
    return HttpGet('/admin/system/role/boundUserPageList', search)
}

/**
 * 绑定菜单权限
 * @param roleId 角色ID
 * @param permissionIds 菜单权限ID集合
 */
export const bindPermissions = (roleId, permissionIds) => {
    return HttpPost('/admin/system/role/bindPermissions', {roleId, permissionIds})
}